package com.hunt.controller;

import com.hunt.model.entity.EastMoneySpider;
import com.hunt.model.entity.NorthCrawler;
import com.hunt.service.AppNorthCrawlerService;
import com.hunt.service.EastMoneySpiderService;
import com.hunt.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalTime;
import java.util.List;

/**
 * @Author: sjs
 * @Date : 2020/10/29
 */

@Api("北上资金,最新一条")
@Controller
@RequestMapping("/app/spider")
public class EastMoneySpiderController extends BaseController {


    @Autowired
    private EastMoneySpiderService EastMoneySpiderService;

    @ApiOperation(value = "北上资金,最新一条", httpMethod = "GET", produces = "application/json", response = Result.class)
    @ResponseBody
    @RequestMapping(value = "getEastSpider", method = RequestMethod.GET)
    public Result getEastSpider() {
        if(isemptytime()){
            return  Result.success( new EastMoneySpider());
        }
        else {
            return Result.success(EastMoneySpiderService.getEastSpider());
        }
    }
    private  boolean isemptytime(){
        LocalTime now = LocalTime.now();
        return now.isAfter(LocalTime.of(9, 15, 0)) && now.isBefore(LocalTime.of(9, 30, 0));
    }
}